// pages/student/random_sign.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    verifyCode:'',
    lid:'',
    uid:'',
    userinfo:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      lid:wx.getStorageSync('lid', this.data.lid),
      userinfo:wx.getStorageSync('userinfo', this.data.userinfo)
    })
  },
  async sign(){
    var _this = this;
    const data = {
      code: _this.data.verifyCode,
      lid: _this.data.lid
    }
    
    if(wx.getStorageSync('userInfo').type == null){
      console.log(data)
      console.log(_this.data.userinfo)
      var result = await wx.User.verifyCode(data)
      if(result == 200){
        var location_x = 0
        var location_y = 0
        
        await wx.User.addNewRecord({
          data: {
            lid: wx.getStorageSync('lid'),
            uid: _this.data.userinfo.uid,
            location_x: location_x,
            location_y: location_y
          }
          
        })
      }
    }
  },
  getCode(e){
    // console.log(e.detail.value)
    this.setData({
      verifyCode:e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})